import axios from "@/utils/common/axios";
import type { ResponseData } from "@/utils/common/axios";

/**
 * pms员工登录
 * @param data
 */
export const empLogin = (data: object): Promise<ResponseData> => {
  return axios.request({
    url: "/ncr/user_login",
    data,
    method: "POST",
  });
};

/**
 * 获取登录用户权限
 */
export const getUserMarks = (): Promise<ResponseData> => {
  return axios.request({
    url: "/system/sec/menu_marks",
    method: "get",
  });
};

/**
 * 获取当前用户信息
 * @returns
 */
export const getUserInfo = (): Promise<ResponseData> => {
  return axios.request({
    url: "/system/employee_info/me",
    method: "get",
  });
};

/**
 * 发送短信
 * @returns
 */
export const sendMessage = (params: any): Promise<ResponseData> => {
  return axios.request({
    url: `/saas-rental-uaa/uaa/shop/admin/sendVerifyCode`,
    method: "get",
    params,
  });
};

/**
 * 修改密码 / 忘记密码
 * @returns
 */
export const changePassword = (params: any): Promise<ResponseData> => {
  return axios.request({
    url: "/saas-rental-uaa/uaa/shop/admin/editPassword",
    method: "PUT",
    params,
  });
};

/**
 * 获取菜单
 */
export const getMenusList = (): Promise<ResponseData> => {
  return axios.request({
    url: "/saas-rental-uaa/uaa/shop/admin/menus",
    method: "GET",
  });
};

/**
 * 获取到企业列表
 */
export const getEnterpriseList = (): Promise<ResponseData> => {
  return axios.request({
    url: "/saas-rental-uaa/uaa/auth/switch",
    method: "GET",
  });
};

/**
 * 获取token
 */
export const getUserToken = (data: object): Promise<ResponseData> => {
  return axios.request({
    url: "/saas-rental-uaa/uaa/auth/oauth/pms/token",
    data,
    method: "POST",
    noToken: true,
  });
};
